<?php /*
  * 打印传递的参数
  */
function write_log($vales){
    $years = date('Y-m');
    $request=Request::createFromGlobals();
    $data = $request->request->all();
    //设置路径目录信息
    $url = './var/logs/txlog/'.$years.'/'.date('Ymd').'_'.$vales.'txt';
    $dir_name=dirname($url);
    //目录不存在就创建
    if(!file_exists($dir_name))
    {
        //iconv防止中文名乱码
        $res = mkdir(iconv("UTF-8", "GBK", $dir_name),0777,true);
    }
    $fp = fopen($url,"a");//打开文件资源通道 不存在则自动创建
    fwrite($fp,var_export($data,true)."\r\n");//写入文件
    fwrite($fp,str_replace("\\/", "/", json_encode($data))."\r\n");//写入文件
    fclose($fp);//关闭资源通道
    return $this->suc('成功');
}

